from fastapi import Request, Response
from fastapi.routing import APIRoute
from afast_core.core_libs.classy_apirouter.group_router import RestInjectForAPIRouter, RestInjectForDocRouter
from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from afast_core.core_libs.classy_apirouter import IHookGroupBaseController
from afast_core.core_libs.classy_apirouter import post
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.oa.controllers.query import \
    OANoticeEmployeeQueryController


#  tags=['测试类装饰器依赖项']

@RestInjectForAPIRouter(prefix='/oa')
@RestInjectForDocRouter(tags=['后台系统-OA模块'])
class AGroupAPIRouterBuilder(IHookGroupBaseController):
    # 定义公共全局的可用的服务，通过request对象进行透传当前的self

    async def before_request(self, curr_apiroute: APIRoute, request: Request) -> None:
        """如果需要修改请求信息，可直接重写此方法"""
        pass
        request.state.api_router_builder = self
        # 如果存在body对象的，在这里读取一下，以备后续的使用
        request.state.schema_param_body = await request.body()
        print("request.state.schema_param_body ", request.state.schema_param_body)

    async def after_request(self, request: Request, response: Response) -> None:
        """请求后的处理"""
        pass

    @post("/notice/employee/query", summary='OA=获取通知信息')
    def admin_notice_employee_query(self, controller: IBaseController = OANoticeEmployeeQueryController):

        return controller.sync_response()

